﻿namespace AlgorithmInterview.Chapter04._01;

// 找出数组中唯一的重复元素
public class Test02
{
    /// <summary>
    /// 累加求合法
    /// </summary>
    /// <param name="array"></param>
    /// <returns></returns>
    public int FindDup(int[] array)
    {
        int len = array.Length;
        int sum = 0;
        int sumArray = 0;
        for (int i = 0; i < len; i++)
        {
            sumArray += array[i];
        }

        for (int i = 1; i < len; i++)
        {
            sum += i;
        }

        return sumArray - sum;
    }
}